package study08;

class Student {
    private String name;
    private int age;

    //    有参构造方法
    public Student(String name, int age){
        this.name = name;
        this.age = age;
    }

    public void show(){
        System.out.println("名字：" + name  + "," +  "年龄：" + age);
    }
}

class Undergraduate extends Student{
    private String degree;

    public Undergraduate(String name, int age, String degree){
        super(name, age);
        this.degree = degree;
    }

    public void show(){
        super.show();
        System.out.println("学位：" + degree);
    }
}


/**
* @author GZQ
* @Date 2023/12/28
 */
public class test04 {
    public static void main(String[] args) {
        // 创建Student对象
        Student student = new Student("顾志强", 23);
        student.show(); // 打印姓名和年龄

        // 创建Undergraduate对象
        Undergraduate undergraduate = new Undergraduate("顾志强", 22, "管理信息");
        undergraduate.show(); // 打印姓名、年龄和学位
    }

}
